// @ts-ignore
/* eslint-disable */
import { request } from "@umijs/max";

/** 获取当前的用户 GET /api/currentUser */
export async function currentUser(options?: { [key: string]: any }) {
  return request<{
    data: API.CurrentUser;
  }>("/api/getInfo", {
    method: "GET",
    ...(options || {}),
  });
}

/** 退出登录接口 POST /api/login/outLogin */
export async function outLogin(options?: { [key: string]: any }) {
  return request<Record<string, any>>("/api/login/outLogin", {
    method: "POST",
    ...(options || {}),
  });
}

/** 登录接口 POST /api/login/account */
export async function getCodeImg(options?: { [key: string]: any }) {
  return request<API.LoginResult>("/api/captchaImage", {
    ...(options || {}),
  });
}
/** 登录接口 POST /api/login/account */
export async function getMenu(options?: { [key: string]: any }) {
  return request<API.MenuResult>("/api/getRouters", {
    ...(options || {}),
  });
}
export async function login(
  body: API.LoginParams,
  options?: { [key: string]: any }
) {
  return request<API.LoginResult>("/api/login", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    data: body,
    ...(options || {}),
  });
}

/** 此处后端没有提供注释 GET /api/notices */
export async function getNotices(options?: { [key: string]: any }) {
  return request<API.NoticeIconList>("/api/notices", {
    method: "GET",
    ...(options || {}),
  });
}

/** 获取规则列表 GET /api/rule */
export async function rule(
  params: {
    // query
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
  },
  options?: { [key: string]: any }
) {
  return request<API.RuleList>("/api/rule", {
    method: "GET",
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** 更新规则 PUT /api/rule */
export async function updateRule(options?: { [key: string]: any }) {
  return request<API.RuleListItem>("/api/rule", {
    method: "POST",
    data: {
      method: "update",
      ...(options || {}),
    },
  });
}

/** 新建规则 POST /api/rule */
export async function addRule(options?: { [key: string]: any }) {
  return request<API.RuleListItem>("/api/rule", {
    method: "POST",
    data: {
      method: "post",
      ...(options || {}),
    },
  });
}

/** 删除规则 DELETE /api/rule */
export async function removeRule(options?: { [key: string]: any }) {
  return request<Record<string, any>>("/api/rule", {
    method: "POST",
    data: {
      method: "delete",
      ...(options || {}),
    },
  });
}

// system/user/deptTree
export async function deptTree(options?: { [key: string]: any }) {
  return request<API.DeptTree>("/api/system/user/deptTree", {
    method: "GET",
    ...(options || {}),
  });
}

// /system/user/list
export async function userList(
  params: {
    // query
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
  },
  options?: { [key: string]: any }
) {
  return request<API.UserList>(
    `/api/system/user/list?${new URLSearchParams(
      params as Record<string, string>
    ).toString()}`,
    {
      method: "GET",

      ...(options || {}),
    }
  );
}
// create system/user
export async function createUser(
  body: API.CreateUserParams,
  options?: { [key: string]: any }
) {
  return request<API.UserInfo>("/api/system/user", {
    method: "POST",

    data: body,
    ...(options || {}),
  });
}

// system/user/changeStatus
export async function changeUserStatus(
  body: { userId: number; status: string },
  options?: { [key: string]: any }
) {
  return request<any>("/api/system/user/changeStatus", {
    method: "PUT",

    data: body,
    ...(options || {}),
  });
}

// /system/user/104 delete
export async function deleteUser(
  userId: string,
  options?: { [key: string]: any }
) {
  return request<any>(`/api/system/user/${userId}`, {
    method: "DELETE",

    ...(options || {}),
  });
}

// get detail   system/user/2
export async function getUserDetail(
  userId: string,
  options?: { [key: string]: any }
) {
  return request<API.UserInfo>(`/api/system/user/${userId}`, {
    method: "GET",

    ...(options || {}),
  });
}
// /system/user update
export async function updateUser(
  body: API.UpdateUserParams,
  options?: { [key: string]: any }
) {
  return request<API.UserInfo>(`/api/system/user`, {
    method: "PUT",
    data: body,
    ...(options || {}),
  });
}

// system/user/resetPwd

export async function resetUserPwd(
  body: { userId: number | string; password: string },
  options?: { [key: string]: any }
) {
  return request<any>("/api/system/user/resetPwd", {
    method: "PUT",

    data: body,
    ...(options || {}),
  });
}

// /system/role/authUser/allocatedList
export async function getAuthUserAllocatedList(
  params: {
    roleId: string | number;
    // query
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
  },
  options?: { [key: string]: any }
) {
  return request<API.UserList>(`/api/system/role/authUser/allocatedList`, {
    method: "GET",
    params,
    ...(options || {}),
  });
}
// /logout
export async function logout(options?: { [key: string]: any }) {
  return request<API.ResponseResult>("/api/logout", {
    method: "POST",
    ...(options || {}),
  });
}
// system/role/authUser/unallocatedList
export async function getAuthUserUnallocatedList(
  params: {
    roleId: string | number;
    // query
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
  },
  options?: { [key: string]: any }
) {
  return request<API.UserList>(`/api/system/role/authUser/unallocatedList`, {
    method: "GET",
    params,
    ...(options || {}),
  });
}
// /system/role/authUser/selectAll
export async function authUserSelectAll(
  body: {
    roleId: string | number;
    userIds: string;
  },
  options?: { [key: string]: any }
) {
  return request<API.ResponseResult>(`/api/system/role/authUser/selectAll`, {
    method: "PUT",
    params: body,

    ...(options || {}),
  });
}
// /system/dict/data/type/sys_show_hide
export async function getSysShowHideDict(options?: { [key: string]: any }) {
  return request<API.DictData[]>("/api/system/dict/data/type/sys_show_hide", {
    method: "GET",

    ...(options || {}),
  });
}

///dev-api/ying/common/product-list
export async function getProductList(params: any, options?: {}) {
  return request<API.ProductList>("/api/ying/common/product-list", {
    method: "GET",
    params,
    ...(options || {}),
  });
}
